/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managerBeanAdmin;

import entity.Department;
import java.util.LinkedHashMap;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import processor.ComplaintFacade;
import processor.DepartmentFacade;
import report.DepartmentReport;

/**
 *
 * @author maynoigi
 */
@ManagedBean
@SessionScoped
public class DepartmentReportBean {
    @EJB
    private DepartmentFacade departmentFacade;

    @EJB
    private ComplaintFacade complaintFacade;
    private List<DepartmentReport> filteredReport;
    private List<DepartmentReport> departmentReport;
    private String departmentName;
    private LinkedHashMap<String, String> departments = new LinkedHashMap<String, String>();

    public LinkedHashMap<String, String> getDepartments() {
        List<Department> temp = departmentFacade.getDepartmentAll();
        for (Department department1 : temp) {
            departments.put(department1.getDepartmentName(), department1.getDepartmentID().toString());
        }
        return departments;
    }

    public void setDepartments(LinkedHashMap<String, String> departments) {
        this.departments = departments;
    }

    public String getDepartmentSelected() {
        return departmentSelected;
    }

    public void setDepartmentSelected(String departmentSelected) {
        this.departmentSelected = departmentSelected;
    }
    private String departmentSelected;

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public List<DepartmentReport> getFilteredReport() {
        return filteredReport;
    }

    public void setFilteredReport(List<DepartmentReport> filteredReport) {
        this.filteredReport = filteredReport;
    }

    public List<DepartmentReport> getDepartmentReport() {
        if(departmentSelected!=null){
        Integer id=Integer.parseInt(departmentSelected);
        Department temp=departmentFacade.getDepartment(id);
        departmentReport = complaintFacade.DepartmentReport(temp);
        departmentName=temp.getDepartmentName();
        }
        return departmentReport;
    }

    public void setDepartmentReport(List<DepartmentReport> departmentReport) {
        this.departmentReport = departmentReport;
    }

    public DepartmentReportBean() {
    }
}
